/**
 * 
 */
package com.miolr.core.dao;

import java.lang.reflect.ParameterizedType;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


/**
 * @author iday
 *
 */
public abstract class AbstractGenericDao<T> implements GenericDao<T> {
	protected Log logger = LogFactory.getLog(this.getClass());
	protected Class<T> persistentClass;
	
	@SuppressWarnings("unchecked")
	public AbstractGenericDao() {
		super();
		if (this.persistentClass == null) {
			try {
				this.persistentClass = (Class<T>) ((ParameterizedType) this
						.getClass().getGenericSuperclass())
						.getActualTypeArguments()[0];
			} catch (Exception e) {
				logger.error("persistentClass init error.", e);
			}
		}
	}

}
